package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EqOperation;
import com.ruoyi.system.service.IEqOperationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 操作记录Controller
 * 
 * @author ruoyi
 * @date 2023-11-20
 */
@RestController
@RequestMapping("/business/operation")
public class EqOperationController extends BaseController
{
    @Autowired
    private IEqOperationService eqOperationService;

    /**
     * 查询操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:operation:list')")
    @GetMapping("/list")
    public TableDataInfo list(EqOperation eqOperation)
    {
        startPage();
        List<EqOperation> list = eqOperationService.selectEqOperationList(eqOperation);
        return getDataTable(list);
    }

    /**
     * 导出操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:operation:export')")
    @Log(title = "操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EqOperation eqOperation)
    {
        List<EqOperation> list = eqOperationService.selectEqOperationList(eqOperation);
        ExcelUtil<EqOperation> util = new ExcelUtil<EqOperation>(EqOperation.class);
        util.exportExcel(response, list, "操作记录数据");
    }

    /**
     * 获取操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:operation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eqOperationService.selectEqOperationById(id));
    }

    /**
     * 新增操作记录
     */
    @PreAuthorize("@ss.hasPermi('business:operation:add')")
    @Log(title = "操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EqOperation eqOperation)
    {
        return toAjax(eqOperationService.insertEqOperation(eqOperation));
    }

    /**
     * 修改操作记录
     */
    @PreAuthorize("@ss.hasPermi('business:operation:edit')")
    @Log(title = "操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EqOperation eqOperation)
    {
        return toAjax(eqOperationService.updateEqOperation(eqOperation));
    }

    /**
     * 删除操作记录
     */
    @PreAuthorize("@ss.hasPermi('business:operation:remove')")
    @Log(title = "操作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eqOperationService.deleteEqOperationByIds(ids));
    }
}
